/* The file is saved in UTF-8 codepage.
 * Check: «Stereotype», Section mark-§, Copyright-©, Alpha-α, Beta-β, Smile-☺
 */
package cz.pecinovsky.english.lootp._101_;


import cz.pecinovsky.english.lootp._000_.Run;

import cz.pecinovsky.english.lootp.utility.IO;
import cz.pecinovsky.english.lootp.utility.Direction8;

// %I+ >111 <114
//import cz.pecinovsky.english.lootp.shapes.Ellipse;
//import cz.pecinovsky.english.lootp.shapes.Multishape;
//import cz.pecinovsky.english.lootp.shapes.Rectangle;
//import cz.pecinovsky.english.lootp.shapes.Triangle;
// %I-

// %X+ <114
import cz.pecinovsky.english.lootp.manager.Ellipse;
import cz.pecinovsky.english.lootp.manager.Multishape;
import cz.pecinovsky.english.lootp.manager.Rectangle;
import cz.pecinovsky.english.lootp.manager.Triangle;

import cz.pecinovsky.english.lootp.manager.Resizer;
import cz.pecinovsky.english.lootp.manager.Mover;


import cz.pecinovsky.english.lootp.manager.CanvasManager_Envelope.               CanvasManager;
// %X-

import java.lang.reflect.Method;



import cz.pecinovsky.english.lootp._101_.MultishapeTest_111_128.MultishapeTest;
////////////////////////////////////////////////////////////////////////////////
//%%+  +++++ End of ignored starting test - place for imports +++++

//%X+ xxxxx Start of the ovejumped text with declaration of the envelope xxxxx
/*******************************************************************************
 *<pre>
 * Předchozí: _111zMnohotvarTest
 *
 * Přidáno:
 *    - testSmoothMovement
 *    - testKompresi
 *
 * Upraveno:
 *      *
 *</pre>
 */
public class MultishapeTest_111_128
{    private MultishapeTest_111_128() {}   static
//%X- ----- End of the ovejumped text with declaration of the envelope -----


/*******************************************************************************
 * The class {@code MultishapeTest} defines a set of unit tests
 * created in the interractive mode
 * during the first introduction of objects.
 *
 * @author Rudolf PECINOVSKÝ
 * @version 6.03.2017 — 2010-11-08
 */
public class MultishapeTest extends junit.framework.TestCase
{
    private Multishape m1;
    private Multishape m2;
//%A+ >114 -115 >119

    private CanvasManager CM;
    private Mover mover;
//%A-



//== CONSTANT CLASS ATTRIBUTES =================================================
//== VARIABLE CLASS ATTRIBUTES =================================================
//== STATIC CONSTRUCTOR (CLASS INITIALIZER, STATIC INICITALIZING BLOCK) ========
//== CONSTANT INSTANCE ATTRIBUTES ==============================================
//== VARIABLE INSTANCE ATTRIBUTES ==============================================
//== CLASS GETTERS AND SETTERS =================================================
//== OTHER NON-PRIVATE CLASS METHODS ===========================================

//##############################################################################
//== CONSTUCTORS AND FACTORY METHODS ===========================================

    /***************************************************************************
     * Creates a test with a given name.
     *
     * @param testName  The name of the created test
     */
    public MultishapeTest(String testName)
    {
        super(testName);
    }



//== PREPARATION AND CLEANING THE FIXTURE ======================================

    /***************************************************************************
     * Creates a test fixture, i.e. a set of objects that will be prepared
     * before each run test.
     */
    @Override
    protected void setUp()
    {
//%I+ <114 >115 -119
//        m1 = new Multishape("m1", new Rectangle(), new Ellipse(), new Triangle());
//        m2 = new Multishape("m2");
//        m2.addShapes(m1);
//        m1.setSizeInFields(33, 25);
//        m1.setPosition(33, 25);
//        m2.addShapes(m1);
//        m1.setPosition(150, 0);
//        m2.creationDone();
//        m2.paint();
//%I-
//%A+ >114 -115 >119
        CM = CanvasManager.getInstance();
        m1 = new Multishape("m1", new Rectangle(), new Ellipse(), new Triangle());
        CM.add(m1);
        m2 = new Multishape("m2");
        CM.add(m2);
        m2.addShapes(m1);
        m1.setSize(33, 25);
        m1.setPosition(33, 25);
        m2.addShapes(m1);
        mover = new Mover(5);
        mover.moveTo(150, 0, m1);
        m2.creationDone();
//%A-
        IO.inform("Multishapes prepared");
    }


    /***************************************************************************
     * Instances of the class {@code TearDown}
     * take care about cleaning up between particular tests
     * They executes the code, which is impossible to incorporate
     * into the method {@link #tearDown()},
     * until the students will not be able to program.
     */
    @Override
    protected void tearDown()
    {
//%X+
        clearMap();
//%X-
    }


//== PRIVATE AND AUXILIARY CLASS METHODS =======================================
//%X+

    /***************************************************************************
     * Froce the class {@link Multishape} to forget
     * all the created multishapes.
     * Method serves only by testing of collection of tests
     * to allow creatd multishape with a name used in the previous test.
     * There is dangerous to use it in standard program,
     * because it allows to create several multishape with the same name.
     */
    private static void clearMap()
    {
        Multishape.Test.removeAll();
    }



//%X-
//== PRIVATE AND AUXILIARY INSTANCE METHODS ====================================
//== EMBEDDED TYPES AND INNER CLASSES ==========================================
//== THE TESTS =================================================================
//
//     /***************************************************************************
//      *
//      */
//     public void testXXX()
//     {
//     }
//

    public void testSmoothMovement()
    {
        Mover mover = new Mover(10);
        mover.moveBy (100,   0, m1);
        mover.moveTo(100, 100, m2);
    }

//%A+ >112

    public void testSmoothResizing()
    {
        Resizer resizer = new Resizer(10);
        resizer.resizeTo(300, 300, m2);
        resizer.resizeByMultipleOf(0.5, m2, Direction8.EAST);
        resizer.resizeBy(50, -50, m2, null);
    }

//%A-
//%X+
     /** */
     public void testFixture() {}
//%X-
    }

//%%- ---- Start of the ovejumped text with closing of the envelope ----
////////////////////////////////////////////////////////////////////////////////
//== TESTING CLASSES AND METHODS ===============================================
//If the class is not the testing one, the folowing two method can be removed
//%X+   Method prepared for inserting into tested classes
     /** */
     public void testFixture() {}

//%X-

    /***************************************************************************
     * Instances of the class {@code TearDown}
     * take care about cleaning up between particular tests
     * They executes the code, which is impossible to incorporate
     * into the method {@link #tearDown()},
     * until the students will not be able to program.
     */
    private static class TearDown implements Run.ITD
    {
        /** {@inheritDoc} */
        @Override
        public void cleanUp()
        {
//            Canvas.clearCanvas();
            CanvasManager.getInstance().removeAll();
            MultishapeTest.clearMap();
        }
    }


    /***************************************************************************
     * Test method.
     */
    public static void test()
    {
        Run.tests(MultishapeTest.class,
                new TearDown(),
                "testSmoothMovement",
                "testSmoothResizing",
                "");
        System.exit(0);
    }
   /** @param args Command line arguments - they are not used. */
    public static void main(String[] args)  {  test();  }
}
